<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/4/24
 * Time: 14:40
 */

namespace app\controller;

use app\BaseController;

use think\facade\Db;

use app\model\Demo;

class Data extends BaseController
{

    public function index()
    {

        //容器的操作
        //$data =  app('db')->table('mail_demo')->where(['id'=>1])->find();

//        $data = Db::table('mail_demo')
//              ->order('id','desc')
//              ->find();
        //模型的操作
        $data =  Demo::find(3);
        echo "<pre>";
        print_r($data);
        echo "</pre>";
        exit();

    }

    /*
     *问题调试的方法
     */
    public function act(){
        //第一种方法打印sql
        //$data = Db::table('mail_demo')->where('id',10)->fetchSql()->find();
        //第二中方法
        $data =Db::table('mail_demo')->where('id',10)->find();
        echo Db::getLastSql();
        //var_dump($data);
    }

}